package io.vincentwinner.systeminfoapi.api;

import com.alibaba.fastjson.JSONObject;
import io.vincentwinner.systeminfoapi.dao.ICentralProcessUnitDao;
import io.vincentwinner.systeminfoapi.service.IDynamicInfoService;
import io.vincentwinner.systeminfoapi.service.IStaticInfoService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/cpu")
public class CentralProcessUnitController {

    @Resource(name = "staticInfoService")
    private IStaticInfoService staticInfoService;

    @Resource(name = "dynamicInfoService")
    private IDynamicInfoService dynamicInfoService;

    @Resource(name = "cpuDao")
    private ICentralProcessUnitDao cpuDao;

    @RequestMapping
    public Object root(){
        JSONObject centralProcessUnitStaticInfo = staticInfoService.getCentralProcessUnitStaticInfo();
        centralProcessUnitStaticInfo.putAll(dynamicInfoService.getCentralProcessUnitDynamicInfo());
        return centralProcessUnitStaticInfo;
    }

    @RequestMapping("/static")
    public Object static$(){
        return staticInfoService.getCentralProcessUnitStaticInfo();
    }

    @RequestMapping("/dynamic")
    public Object dynamic(){
        return dynamicInfoService.getCentralProcessUnitDynamicInfo();
    }

    @RequestMapping("/vendor")
    public Object vendor(){
        return cpuDao.getVendor();
    }

    @RequestMapping("/name")
    public Object name(){
        return cpuDao.getCPUName();
    }

    @RequestMapping("/family")
    public Object family(){
        return cpuDao.getFamily();
    }

    @RequestMapping("/logicCoreNum")
    public Object logicalCoreNum(){
        return cpuDao.getLogicalCoreNum();
    }

    @RequestMapping("/physicalCoreNum")
    public Object physicalCoreNum(){
        return cpuDao.getPhysicalCoreNum();
    }

    @RequestMapping("/model")
    public Object model(){
        return cpuDao.getModel();
    }

    @RequestMapping("/stepping")
    public Object stepping(){
        return cpuDao.getStepping();
    }

    @RequestMapping("/vendorFreq")
    public Object vendorFreq(){
        return cpuDao.getVendorFreq();
    }

    @RequestMapping("/maxFreq")
    public Object maxFreq(){
        return cpuDao.getMaxFreq();
    }

    @RequestMapping("/isCpu64Bit")
    public Object isCpuBit(){
        return cpuDao.isCpu64Bit();
    }

    @RequestMapping("/usage")
    public Object usage(){
        return cpuDao.getUsage();
    }

}
